import java.awt.*;
import java.util.ArrayList;

/**
 * Created by obila_000 on 2014/10/17.
 */
public class Gizmos {
    enum Gizmos_type{
        SQURE,
        TRANGLE,
        CIRCLE,
        FLIPPER_RIGHT,
        FLIPPER_LEFT,
        LBLOCK
    }
    protected float x;
    protected float y;
    protected Color color;
    protected ArrayList<Gizmos> connectedGizmos;
    protected String gizmosID;
    protected float rotation;
    protected float scare;

    // Keep track of the animation window that will be drawing this ball.
    protected AnimationWindow win;
    protected Gizmos_type type;
    protected float pellucidity = 1.0f;  //透明度
    protected Shape shape;
    protected boolean doAction;

    /**
     * Constructor.
     * @param win Animation window that will be drawing this ball.
     */
    public Gizmos(AnimationWindow win) {
        this.win = win;
        this.x = 0;
        this.y = 0;
        this.color = Color.BLACK;
        this.connectedGizmos = new ArrayList<Gizmos>();
        gizmosID = "";
        rotation = 0;
        scare = 1.0f;
        doAction = false;
    }

    /**
     * @modifies the Graphics object <g>.
     * @effects paints a circle on <g> reflecting the current position
     * of the ball.
     * @param g Graphics context to be used for drawing.
     */
    public void paint(Graphics g) {

    }

    /**
     * @return the smallest rectangle that completely covers the current
     * position of the ball.
     */
    public Rectangle boundingBox() {
        return null;
    }

    /**
     * 判断是否与小球发生碰撞并改变小球速度
     * @param ball
     */
    public void judgeCollispeWithBall(BouncingBall ball){

    }

    /**
     * 添加和绑定的小物件
     * @param gizmos
     */
    public void addConnectedGizmos(Gizmos gizmos){
        connectedGizmos.add(0,gizmos);
    }

    /**
     * 得到所有与此物件绑定的小物件
     * @return
     */
    public ArrayList<Gizmos> getConnectedGizmos(){
        return connectedGizmos;
    }

    public void setRotation(float rotation){
        this.rotation=rotation;
    }

    public float getRotation(){
        return rotation;
    }

    public void setScare(float scare){
        this.scare = scare;
    }

    public float getScare(){
        return scare;
    }

    public void setGizmosID(String id){
        this.gizmosID = id;
    }

    public String getGizmosID(){
        return gizmosID;
    }

    protected void setType(Gizmos_type type){
        this.type = type;
    }

    public Gizmos_type getType(){
        return type;
    }

    public void setPellucidity(float pellucidity){
        this.pellucidity = pellucidity;
    }

    public float getPellucidity(){
        return pellucidity;
    }

    public void setPosition(float x, float y){
        this.x = x;
        this.y = y;
    }

    public Point getPostion(){
        return new Point((int)(x),(int)(y));
    }

    public void setShape(Shape shape){
        this.shape = shape;
    }

    public Shape getShape(){
        return shape;
    }

    /**
     * 判断一个点是否在小物件范围内
     * @param point
     * @return
     */
    public boolean inGizmos(Point point){
        if(this.getShape()!=null&&this.getShape().contains(point)){
            return true;
        }
        return false;
    }

    /**
     * 开始进行动作
     */
    public void startDoAction(){
        doAction = true;
    }

    /**
     * 被触发时执行的动作
     */
    public void action(){

    }

    /**
     * 被选中时改变状态
     */
    public void startFocusAnimation(){

    }

    /**
     * 取消选中时改变状态
     */
    public void startLeaveAnimation(){

    }
}
